#!/usr/bin/env python3

import os
import time

def main():
    print("main start pid = ", os.getpid())
    pid = os.fork()
    if pid == 0:    #子进程要执行的代码
        print("child pid = %d, ppid = %d" % (os.getpid(), os.getppid()))
        time.sleep(10)
        print("child exit pid = %d, ppid = %d" % (os.getpid(), os.getppid()))
        os._exit(0)

    #父进程要执行的代码
    print("main fork end curPid = %d, pid = %d" % (os.getpid(), pid))
    print("main parent end....")

if __name__ == "__main__":
    main()
